package com.gzsxy.esjy.sign.service.impl;


import com.gzsxy.esjy.sign.cache.SignCacheManager;
import com.gzsxy.esjy.sign.dto.InnerSignDto;
import com.gzsxy.esjy.sign.service.GSSignBusinessService;
import lombok.extern.slf4j.Slf4j;

/**
 * 默认签名处理实现
 * @author zhangxiaolong
 * @since 2022/7/15
 */
@Slf4j
public class DefaultBusinessHandlerServiceImpl extends AbstractSignHandler implements GSSignBusinessService {

    public DefaultBusinessHandlerServiceImpl(SignCacheManager signCacheManager, Integer serverPort) {
        this.signCacheManager = signCacheManager;
        this.serverPort = serverPort;
    }

    /**
     * 签名中
     *
     * @param signDto 签名实体
     */
    @Override
    public void signAck(InnerSignDto signDto) {
        log.info("默认处理:ack收到确认回复,devType:{},id:{},extend:{}", signDto.getSignDevType(), signDto.getTaskId(), signDto.getExtend());
    }

    /**
     * 签名成功
     *
     * @param signDto 签名实体
     */
    @Override
    public void signSuccess(InnerSignDto signDto) {
        log.info("默认处理:签名成功,devType:{},id:{},extend:{}", signDto.getSignDevType(), signDto.getTaskId(), signDto.getExtend());
    }

    /**
     * 取消签名
     *
     * @param isDeviceCancel 是否设备取消
     * @param signDto        签名实体
     */
    @Override
    public void cancelSign(InnerSignDto signDto, boolean isDeviceCancel) {
        log.info("默认处理:{}取消签名,devType:{},id:{},extend:{},code:{}, msg:{}", isDeviceCancel ? "设备点击" : "前端点击",
                signDto.getSignDevType(), signDto.getTaskId(), signDto.getExtend(), signDto.getCode(), signDto.getMsg());
    }

    /**
     * 签名异常，未处理的指令请求
     *
     * @param signDto 签名实体
     */
    @Override
    public void signException(InnerSignDto signDto) {

    }

}
